#ifndef MODULES_CORE_TIMER_H_
#define MODULES_CORE_TIMER_H_
#include "../common.h"

static int _timerNameCount = 0;

class Timer {
private:
	esp_timer_handle_t timerHandle = 0;
	uint64_t millisecond;
	void _init(const char *name, esp_timer_cb_t cb) {
		esp_timer_create_args_t myArgs;
		myArgs.callback = cb;
		myArgs.name = name;
		esp_timer_create(&myArgs, &timerHandle);
	}
public:
	Timer(uint64_t millisecond, esp_timer_cb_t cb) :
					millisecond(millisecond) {
		this->_init("timer:" + _timerNameCount++, cb);
	}
	Timer(const char *name, uint64_t millisecond, esp_timer_cb_t cb) :
					millisecond(millisecond) {
		this->_init(name, cb);
	}
	~Timer() {

	}
	void startOnce();
	void startPeriodic();
	void stop();
};

#endif /* MODULES_CORE_TIMER_H_ */
